gl: Warn the user if they request a GL context version less than 3.2
authorNiels Nesse <nnesse@sonic.net>
Wed, 11 Feb 2015 04:35:01 +0000 (20:35 -0800)
committerAlexander Larsson <alexl@redhat.com>
Fri, 6 Mar 2015 13:02:55 +0000 (14:02 +0100)
If the user requests a version less than 3.2 the version is forced to 3.2.
Previous checking code have an inconsistent behavior depending on which
minor version number was specified. This is avoided now by temporarily
converting the major/minor pair into a single integer.

https://bugzilla.gnome.org/show_bug.cgi?id=744288

gdk/gdkglcontext.c

index 1d88a48fc1f30abbe051bef58588ddf62648d161..306e0ae37e9a04d9b7c6002f2dc3694dd55ad03d 100644 (file)
@@ -492,6 +492,7 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
                                      int           major,
                                      int           minor)
 {
+  int version;
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
 
   g_return_if_fail (GDK_IS_GL_CONTEXT (context));
@@ -505,13 +506,15 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
       return;
     }
 
-  priv->major = MAX (major, 3);
-
-  /* we only support versions ≥ 3.2 */
-  if (priv->major == 3)
-    priv->minor = MAX (minor, 2);
-  else
-    priv->minor = minor;
+  /* Enforce a minimum context version number of 3.2 */
+  version = (major * 100) + minor;
+  if (version < 302)
+    {
+      g_warning ("gdk_gl_context_set_required_version - GL context versions less than 3.2 are not supported.");
+      version = 302;
+    }
+  priv->major = version / 100;
+  priv->minor = version % 100;
 }
 
 /**